package module.building.view.buildingProgressBar
{
	import com.darwin.darwinDisplay.DarBitmapMovieClip;
	import com.darwin.darwinDll.Dll;
	import com.darwin.darwinDll.core.DllItem;
	import com.darwin.darwinMVC.mvc.ModelData;
	import com.darwin.darwinUI.controls.Label;
	import com.darwin.darwinUI.controls.ProgressBar;
	import com.darwin.darwinUI.core.UIComponent;
	import com.darwin.darwinUI.general.TextFieldFactory;
	
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	
	import main.AppCommonData;
	import main.AppDataSource;
	
	import module.main.model.dataObj.UserInfoObj;
	import module.main.view.ResourceConst;
	
	public class BuildingProgressBar extends UIComponent
	{
		
		private var _baseProgressBar:ProgressBar;
		private var _timeLabel:Label;
		
		public function BuildingProgressBar()
		{
			super();
			init();
		}
		
		private function init():void {
			this.width = 120;
			initBar();
			initLabel();
		}
		
		private function initBar():void{
			_baseProgressBar  = new ProgressBar();
			var backClass:Class =  Dll.getInstance().getSynPreloadRes("",ResourceConst.BUILDING_BAR_BG,DllItem.TYPE_SWF);
			var back:Sprite = new backClass();
			var barClass:Class = Dll.getInstance().getSynPreloadRes("",ResourceConst.BUILDING_BAR_SKIN,DllItem.TYPE_SWF)
			var bar:Sprite = new barClass();
			bar.width   = back.width - 12;
			bar.height = back.height - 12;
			_baseProgressBar.background  =back;
			_baseProgressBar.bar  = bar;
			_baseProgressBar.barOffX = 6;
			_baseProgressBar.barOffY = 6;
			_baseProgressBar.y = 20;
			addChild(_baseProgressBar);
		}
		
		private function initLabel():void{
			_timeLabel =new Label("");
			addChild(_timeLabel);
		}
		
		public function setLeftTime(str:String):void{
			_timeLabel.text = str;
			_timeLabel.x = (this.width - _timeLabel.width)/2;
		}
		
		/**
		 * 设置进度条 进度（0-1） 
		 * @param value
		 * 
		 */		
		public function set progress(value:Number):void{
			_baseProgressBar.progress = value;
			_baseProgressBar.dispatchEvent(new Event(Event.RENDER));
		}
	}
}